package com.taxigang.client.facebook;

import com.google.gwt.core.client.JsArray;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.Command;
import com.taxigang.client.micro.TaxiGangCreator;

abstract public class PostCommand implements Command{


	protected Posting[] postings;
	
	private int i;
	public PostCommand(){}
	
	public Posting[] getPostingList(){
		return postings;
	}
	
	public void setPostingList(JsArray<PlaceRefJso> places){
		postings = new Posting[places.length()];
		for (int i = 0, n = places.length(); i < n; ++i) {
			PlaceRefJso place = places.get(i);
			Posting placePosting = new Posting(place.getCategory());
			placePosting.setQuestion(TaxiGangCreator.taxiGangConstants.wantToPost2()+places.get(i).getName());
			placePosting.setName(places.get(i).getName());
			placePosting.setId(places.get(i).getId());
			postings[i]=placePosting;
		}
	}

	public Posting getNext() {
		Posting posting = null;
		while (true){
			i++;
			if (i<postings.length){
				if (postings[i].getCategory().contains("Club")){
					posting=postings[i];
					break;
				}
			} else {
				break;
			}
		}
		return posting;
	}
	

}
